/*
 * Stack.cpp
 *
 *  Created on: 2011-04-12
 *      Author: tony
 */

#include "Stack.h"
#include <assert.h>

Stack::Stack(): top(NULL) {
}

Stack::~Stack() {
	while (top != NULL)
		pop();
	top = NULL;
}

void Stack::push( char d ){
   top = new Node( d, top );
}

char  Stack::pop(){
	assert( top != NULL );
	Node* result = top;
	top = top->getNext();
	char d = result->get();
	delete result;
	return d;
}

bool Stack::is_empty(){
	return top == NULL;
}
